package com.ruoyi.common.base.model.extend;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * BaseValidError
 *
 * @author HHKJ-SERVER-ZJ
 * @since 2023/11/3 10:40
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ValidError<T> implements Serializable {

    /** 使用者自定义字段，区分报错类型 **/
    private String customizeCode;

    /** 排序序号 */
    private Integer orderNum;

    /** 对应数据 */
    private T data;

    /** 错误信息列表 */
    private List<String> errorInfoList;

    public ValidError(Integer orderNum, T data, String errorInfo) {
        this.orderNum = orderNum;
        this.data = data;
        this.errorInfoList = Collections.singletonList(errorInfo);
    }

    public ValidError(Integer orderNum, T data, String errorInfo, String customizeCode) {
        this.orderNum = orderNum;
        this.data = data;
        this.errorInfoList = Collections.singletonList(errorInfo);
        this.customizeCode = customizeCode;
    }
}
